import Taro, { Component } from '@tarojs/taro'
import PropsType from 'prop-types'
import classnames from 'classnames'
import { View, Text } from '@tarojs/components'
import { AtButton } from 'taro-ui'
import '../styles/financinginfo.scss'

export default class DFinancingInfo extends Component {

    onDetailHandle() {
        this.props.onDetailHandle && this.props.onDetailHandle(...arguments)
    }

    onHanldeFirst(e) {
        e.stopPropagation()
        this.props.onHanldeFirst && this.props.onHanldeFirst()
    }

    render() {
        const {
            className,
            firstText,
            status,
            id,
            order,
            orstatus,
            date,
            days,
            way,
            number,
            address,
            money
        } = this.props
        return (
            <View className={classnames("b_financinginfo", className)}>
                {
                    // list && list.map((item, i) => {
                    <View className='b_financinginfo__item' onClick={this.onDetailHandle.bind(this)}>
                        <View className='item_title b_financinginfo__item_header'>
                            <View className='item_title__left'>
                                <Text className='item_title__left_icon'>库</Text>
                                {
                                    order && <Text className='b_financinginfo__text'>{order}</Text>
                                }
                            </View>
                            {
                                orstatus && <View className='item_title__right'>
                                    <Text className='b_financinginfo__text'>{orstatus}</Text>
                                </View>
                            }
                        </View>
                        <View className='item_title'>
                            <View className='item_title__left'>
                                <Text className='b_financinginfo__title'>用款日期</Text>
                                {
                                    date && <Text className='b_financinginfo__text'>{date}</Text>
                                }
                            </View>
                        </View>
                        <View className='b_financinginfo__item_days item_title'>
                            <View className='item_title__left_date'>
                                <Text className='b_financinginfo__title'>用款天数</Text>
                                {
                                    days && <Text className='b_financinginfo__text'>{days}</Text>
                                }
                            </View>
                        </View>
                        <View className='b_financinginfo__item_time item_title'>
                            <View className='item_title__left'>
                                <Text className='b_financinginfo__title'>监管方式</Text>
                                {
                                    way && <Text className='b_financinginfo__text'>{way}</Text>
                                }
                            </View>
                            {
                                number && <View className='item_title__right'>
                                    <Text className='item_title__right_num'>共{number}台</Text>
                                </View>
                            }

                        </View>
                        <View className='b_financinginfo__item_time item_title'>
                            <View className='item_title__left'>
                                <Text className='b_financinginfo__title'>监管地址</Text>
                                {
                                    address && <Text className='b_financinginfo__text'>{address}</Text>
                                }
                            </View>
                            {
                                money && <View className='item_title__right'>
                                    <Text className='item_title__right_money'>￥{money}</Text>
                                </View>
                            }
                        </View>
                        <View className='item_title item_title__btn'>
                            <View className='item_title__btn_right'>
                                {
                                    firstText && <AtButton className='item_btn item_btn__default' onClick={this.onHanldeFirst.bind(this)}>{firstText}</AtButton>
                                }
                            </View>
                        </View>
                    </View>
                    // })
                }
            </View>
        )
    }
}

DFinancingInfo.defaultProps = {
    className: '',
    firstText: '',
    secodeText: '',
    status: '',
    id: '',
    order: '',
    orstatus: '',
    date: '',
    days: '',
    way: '',
    number: '',
    address: '',
    money: '',
    onHanldeFirst: () => { },
    onHanldeSecode: () => { },
    onDetailHandle: () => { }
}
DFinancingInfo.PropsType = {
    className: PropsType.oneOfType[PropsType.string, PropsType.object],
    item: PropsType.object,
    firstText: PropsType.string,
    status: PropsType.string,
    secodeText: PropsType.string,
    onHanldeFirst: PropsType.func,
    onHanldeSecode: PropsType.func,
    onDetailHandle: PropsType.func,
    id: PropsType.string,
    order: PropsType.string,
    orstatus: PropsType.string,
    date: PropsType.string,
    days: PropsType.string,
    way: PropsType.string,
    number: PropsType.string,
    address: PropsType.string,
    money: PropsType.string
}
